home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / cuj0796.zip / BELL.ZIP / FORFUN.C next >
Text File  |  1996-04-23  |  596b  |  23 lines

  1. /*  Listing 1  */
  2.  
  3. void forfun (int *r, int *startval, int *endval,
  4.      int loop, int lastloopsub)
  5. {
  6. /*  initialization  */
  7. r[loop] = startval[loop];
  8.  
  9. /*  continuation condition  */
  10. while ( r[loop] <= endval[loop] ){
  11.       /*  recursion termination condition  */
  12.       if (loop == lastloopsub){
  13.             /*  do work of the innermost loop  */
  14.             work(r, lastloopsub);
  15.             }
  16.       else{
  17.             forfun(r,startval,endval,(loop+1),lastloopsub);
  18.             }
  19.       /*  Increment looping variable  */
  20.       r[loop]++;
  21.       }
  22. }  /*  end of forfun()  */
  23.